home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997: The Complete Utilities Toolkit / macworld-complete-utilities-1997.iso / Programming / Little Smalltalk v3.1.5 / Smalltalk Source / notifier.st < prev    next >
Encoding:
Text File  |  1995-07-01  |  2.4 KB  |  95 lines  |  [TEXT/KAHL]

  1. * ***
  2. * Methods for a system error notifier
  3. *
  4. * Julian Barkway (c) October 1994. All rights reserved. 
  5. *
  6. * v3.1.3 - Initial release.
  7. * v3.1.5 - Modify to use enhanced pane protocol.
  8. *
  9. * ***
  10.  
  11. Class NotifierTextPane TextPane
  12. Class Notifier Object nWindow pMenu theText
  13.  
  14. "Process::trace modified to write results to a string"
  15.  
  16. Methods Process 'tracing'
  17.     traceToMem    | link m r s |
  18.         " first yield scheduler, forcing store of linkPointer"
  19.         scheduler yield.
  20.         linkPointer isNil ifTrue: [
  21.             ^ 'No trace-back data available'
  22.         ].
  23.         link <- linkPointer.
  24.         link <- stack at: link + 1.
  25.         s    <- ''.
  26.         " then trace back chain "
  27.         [ link notNil ] whileTrue: [
  28.             m <- stack at: link + 3. 
  29.             m notNil ifTrue: [ 
  30.                 s <- s , (m signature) , ' ( '.
  31.                   r <- stack at: link + 2.
  32.                   (r to: link-1) do: [:x | 
  33.                       s <- s, ((stack at: x) class asString), ' '
  34.                   ].
  35.                 s <- s, ')', newLine 
  36.             ].
  37.             link <- stack at: link
  38.         ].
  39.         ^ s
  40. ]
  41.  
  42. Methods Smalltalk 'doit'
  43.     error: aString    | s txt |
  44.         " print a message, and remove current process "
  45.         txt <- scheduler currentProcess traceToMem.
  46.         Notifier new; notify: aString withText: txt.
  47.         (scheduler currentProcess) terminate
  48. ]
  49.  
  50. Methods NotifierTextPane 'all'
  51.     openOn: theText in: aWindow withBoundsFrom: topLeft to: bottomRight
  52.         self boundsFrom: topLeft to: bottomRight;
  53.              owner: self;
  54.              attachTo: aWindow withSizing: (1 @ 1) andLineLength: (80 * 9);
  55.              font: 'monaco'; fontSize: 9; print: theText.
  56. |
  57.     createPopUpMenu
  58.         pMenu <- PopUpMenu new; owner: self; create.
  59.         pMenu addItem: 'Close' action: #close;
  60.               addItem: 'Debug' action: #debug;
  61.               disableItem: 2
  62. |
  63.     close
  64.         parentWindow close
  65. |
  66.     debug
  67.         ^ nil
  68. ]
  69.  
  70. Methods Notifier 'all'
  71.     notify: titleText withText: text
  72.         theText <- text.
  73.         self openOn: text withTitle: titleText
  74. |        
  75.     openOn: theText withTitle: aTitle
  76.     | maxW maxH topCentre origin ww wh |
  77.         maxW <- (smalltalk getMaxScreenArea) right.
  78.         maxH <- (smalltalk getMaxScreenArea) bottom.
  79.         topCentre  <- (0@0).
  80.         origin     <- (0@0).
  81.         topCentre x: ((maxW / 2) truncated); y: 150.
  82.         origin <- topCentre - (175@0).
  83.         maxW <- 350 min: ((origin x) + (maxW - 70)).
  84.         maxH <- 100 min: ((origin y) + (maxH - 70)).
  85.         self makePane: (Window new; title: aTitle; openAt: origin withSize: (maxW@maxH))
  86.              withText: theText.
  87. |
  88.     makePane: aWindow withText: theText
  89.     | ww wh np |
  90.         ww <- (aWindow size) x + 1.
  91.         wh <- (aWindow size) y + 1.
  92.         np <- NotifierTextPane new.
  93.         np openOn: theText in: aWindow withBoundsFrom: (-1 @ -1) to: (ww @ wh)
  94. ]
  95.